package com.yx.cloud.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.gson.Gson;
import com.iot.sweeper.AppContext;
import com.yx.cloud.R;
import com.yx.cloud.base.BaseActivity;
import com.yx.cloud.bean.MessageCenterBean;
import com.yx.cloud.utils.StringUtils;
import com.iot.product.sweeper.bean.Robot;
import com.iot.common.utils.LogUtils;

public class MessageCenterDetailsActivity extends BaseActivity implements View.OnClickListener {
    private ImageView ivMessageConterDetailsReturn;
    private TextView tvMessageConterDetailsTitle, tvMessageDetailsTitle, tvMessageDetailsContent,
            tvMessageDetailsTime, tvMessageDetailsRobotName;
    private Robot device;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.message_center_details_activity);
        initView();
        initData();
    }

    private void initView() {
        tvMessageDetailsTitle = findViewById(R.id.tv_messageDetailsTitle);
        tvMessageDetailsContent = findViewById(R.id.tv_messageDetailsContent);
        tvMessageDetailsTime = findViewById(R.id.tv_messageDetailsTime);
        tvMessageDetailsRobotName = findViewById(R.id.tv_messageDetailsRobotName);
    }

    private void initData() {
        device = AppContext.get().getCurrentDevice();
        String source = getIntent().getStringExtra("source");
        MessageCenterBean details = (MessageCenterBean) getIntent().getSerializableExtra("details");
        LogUtils.i("消息 详情 ：" + new Gson().toJson(details));
        if ("warning".equals(source)) {
            tvMessageConterDetailsTitle.setText("XXX");
        } else if ("inform".equals(source)) {
            tvMessageConterDetailsTitle.setText("BBBB");
        }
        tvMessageDetailsTitle.setText(details.getTitle());
        tvMessageDetailsContent.setText(details.getEvent_desc());
        tvMessageDetailsTime.setText(StringUtils.timeStamp2Date(details.getTime(), null) + "");
        tvMessageDetailsRobotName.setText(device.getName());
        ivMessageConterDetailsReturn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
    }
}
